package com.templeix.jfinal.base;

import java.util.List;

import org.apache.log4j.Logger;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Table;
import com.jfinal.plugin.activerecord.TableMapping;


/**
 * Model 优化修改
 * 
 */
public class BaseModel<M extends Model<M>> extends Model<M> {

	private static final Logger log = Logger.getLogger(BaseModel.class);
	private static final long serialVersionUID = 1L;


	public List<M> findByWhere(String where, Object... paras) {
		return findByWhereAndColumns(where, "*", paras);
	}


	public List<M> findByWhereAndColumns(String where, String columns, Object... paras) {
		String sql = " select " + columns + " from " + getTable().getName() + " " + where;
		return find(sql, paras);
	}
	
	public Table getTable() {
		return TableMapping.me().getTable(getClass());
	}
}
